package com.example.byd.ui.dashboard

import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModelProvider
import com.example.byd.R
import com.example.byd.databinding.FragmentDashboardBinding

class DashboardFragment : Fragment() {

    private var _binding: FragmentDashboardBinding? = null

    // This property is only valid between onCreateView and
    // onDestroyView.
    private val binding get() = _binding!!

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View {
        val dashboardViewModel =
            ViewModelProvider(this).get(DashboardViewModel::class.java)

        _binding = FragmentDashboardBinding.inflate(inflater, container, false)
        val root: View = binding.root

        val textView: TextView = binding.textDashboard
        dashboardViewModel.text.observe(viewLifecycleOwner) {
            textView.text = it
        }
//
//       val  mTxtWeb:TextView =  findViewById(R.id.bilibili);
//        root.bilibi

        val btextView: TextView = binding.textBilibili
        btextView.text="akp唯一发布渠道：B站 阳哼哼9 点击前往"
        btextView.setOnClickListener(
            object : View.OnClickListener {
                override fun onClick(v: View?) {


                    val it: Intent = Intent(Intent.ACTION_VIEW, Uri.parse("https://space.bilibili.com/365258972"));
                    it.setClassName("com.android.browser", "com.android.browser.BrowserActivity");
                    startActivity(it);



                    Log.i("bydautosong","啦啦啦啦啦")
                }
            }
        )

//        btextView.callOnClick()

        return root
    }

    override fun onDestroyView() {
        super.onDestroyView()
        _binding = null
    }
}

